// Copyright 2011 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


/**
 * @fileoverview Handles namespace creation for the LayerManager.
 *
 * Public properties:
 *   createNamespace - Creates the namespace for the LayerManager.  The
 *       new namespace will deviate from the original as the public prototype
 *       functions will be added directly to each new LayerManager object in
 *       the form of forwarding functions.  Forwarding functions are used to
 *       ensure proper mapping if the module is optimized and name reduction is
 *       used.
 *
 * @author jasonstredwick@google.com (Jason Stredwick)
 */


goog.provide('shellExtension.namespace');

goog.require('shellExtension.LayerManager');


/**
 * Creates the shellExtension.LayerManager namespace.
 * @return {!Object} The namespace.
 */
shellExtension.namespace.create = function() {
  return {
    'shellExtension': {
      'LayerManager': function() {
        var lm = new shellExtension.LayerManager();

        this['onLogUpdated'] = lm.onLogUpdated;
        this['onInjectionComplete'] = lm.onInjectionComplete;

        // Must explicitly add each one using the dot notation to ensure proper
        // translation if code is optimized and name reduction is used.
        this['add'] = function(args) { lm.add(args); };
        this['changeOndemand'] = function(args) { lm.changeOndemand(args); };
        this['changeState'] = function(args) { lm.changeState(args); };
        this['clear'] = function(args) { return lm.clear(args); };
        this['getLayerDetails'] =
            function(args) { return lm.getLayerDetails(args); };
        this['getStatus'] = function(args) { return lm.getStatus(args); };
        this['inject'] = function(args) { lm.inject(args); };
        this['isCached'] = function(args) { return lm.isCached(args); };
        this['remove'] = function(args) { return lm.remove(args); };
        this['resetFromCache'] = function(args) { lm.resetFromCache(args); };
        this['resetLayer'] = function(args) { lm.resetLayer(args); };
      }
    }
  };
};

